HAL DCMI I/O operation functions migration

This section provides information about the HAL DCMI I/O operation functions migration.

The updates made in HAL2 corresponds to:

Renaming the function HAL_DCMI_Start_DMA() to HAL_DCMI_StartPipe_DMA() with an additional parameter pipe corresponding to the capture pipe thus in preparation of the DCMIPP peripheral supporting multiple capture pipes.

The parameter Length given to HAL_DCMI_Start_DMA() in HAL1 is in word unit (32 bits) whereas in HAL2 the parameter size_byte given to HAL_DCMI_StartPipe_DMA() is in byte unit (8 bits).

Note

When working on DCMI peripheral there is only one pipe which it is pipe 0.

HAL DCMI starts data capture using DMA

In HAL1 the parameter Length given to HAL_DCMI_Start_DMA() must be set to the size of the frame to be captured in words since the unit of the DMA associated to DCMI is a word (32 bits).

In HAL2 the parameter size_byte given to HAL_DCMI_StartPipe_DMA() must be set to the size of the frame to be captured in bytes (8 bits).

HAL1

HAL2

Function prototype

HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef *hdcmi,
                                      uint32_t DCMI_Mode,
                                      uint32_t pData,
                                      uint32_t Length);
hal_status_t HAL_DCMI_StartPipe_DMA(hal_dcmi_handle_t *hdcmi,
                                    hal_dcmi_pipe_t pipe,
                                    hal_dcmi_capture_t capture,
                                    uint32_t dest_addr,
                                    uint32_t size_byte)

Example usage

#define FRAME_BUFFER_ADDR   (0x24000000U)
#define FRAME_WORDS         (640U * 480U * 2U / 4U)
/* The frame is 640x480 pixels, 2 bytes per pixel,
   divided by 4 bytes per word */

DCMI_HandleTypeDef hdcmi1;
(void)HAL_DCMI_Start_DMA(&hdcmi1,
                          DCMI_MODE_SNAPSHOT,
                          (uint32_t*)FRAME_BUFFER_ADDR,
                          FRAME_WORDS);
#define FRAME_BUFFER_ADDR   (0x24000000U)
#define FRAME_BYTES         (640U * 480U * 2U)
/* As the frame is 640x480 pixels and the configuration
   is set to RGB565 which give 2 bytes per pixel*/

hal_dcmi_handle_t hdcmi1;
(void)HAL_DCMI_StartPipe_DMA(&hdcmi1,
                              HAL_DCMI_PIPE_0,
                              HAL_DCMI_CAPTURE_SNAPSHOT,
                              FRAME_BUFFER_ADDR,
                              FRAME_BYTES);
  • Related concepts:

Revised and optimized HAL API status returns. Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels..


HAL DCMI suspend data capture

HAL1

HAL2

Function prototype

HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef *hdcmi)
hal_status_t HAL_DCMI_SuspendPipe(hal_dcmi_handle_t *hdcmi,
                                  hal_dcmi_pipe_t pipe)

Example usage

DCMI_HandleTypeDef hdcmi1;
(void)HAL_DCMI_Suspend(&hdcmi1);
hal_dcmi_handle_t hdcmi1;
(void)HAL_DCMI_SuspendPipe(&hdcmi1,
                            HAL_DCMI_PIPE_0);
  • Related concepts:

Revised and optimized HAL API status returns. Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels..


HAL DCMI resume data capture

HAL1

HAL2

Function prototype

HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef *hdcmi)
hal_status_t HAL_DCMI_ResumePipe(hal_dcmi_handle_t *hdcmi,
                                  hal_dcmi_pipe_t pipe)

Example usage

DCMI_HandleTypeDef hdcmi1;
(void)HAL_DCMI_Resume(&hdcmi1);
hal_dcmi_handle_t hdcmi1;
(void)HAL_DCMI_ResumePipe(&hdcmi1,
                          HAL_DCMI_PIPE_0);
  • Related concepts:

Revised and optimized HAL API status returns. Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels..


HAL DCMI stop data capture

HAL1

HAL2

Function prototype

HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef *hdcmi)
hal_status_t HAL_DCMI_StopPipe_DMA(hal_dcmi_handle_t *hdcmi,
                                    hal_dcmi_pipe_t pipe)

Example usage

DCMI_HandleTypeDef hdcmi1;
(void)HAL_DCMI_Stop(&hdcmi1);
hal_dcmi_handle_t hdcmi1;
(void)HAL_DCMI_StopPipe_DMA(&hdcmi1,
                            HAL_DCMI_PIPE_0);
  • Related concepts:

Revised and optimized HAL API status returns. Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels..